package priv.conceit.study.book.thread.chapter3.parts5;

/**
 * 3.5
 * 获取当前线程的引用
 * {@link Thread#currentThread()}
 *
 * @author Conceit
 * @since 1.0.0, 2019/6/18
 */
public class CurrentThread {

	public static void main(String[] args) {
		currentThread();
	}

	private static void currentThread() {
		Thread thread = new Thread() {
			@Override
			public void run() {
				System.out.println("Thread.currentThread()-->" + Thread.currentThread());
				System.out.println("this-->" + this);
				System.out.println("Thread.currentThread()==this-->" + (Thread.currentThread() == this));
			}
		};
		thread.setName("thread-1");
		thread.start();

		//ture
		System.out.println("main".equals(Thread.currentThread().getName()));

	}

}
